home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 29 / CDT29.iso / e-Mail / WorldClient Pro 2.2.3 / wcsetup.exe / WEBHELP.ZIP / hhapplet / SiteMapParserToContents.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-10-21  |  4.5 KB  |  256 lines

  1. package hhapplet;
  2.  
  3. import java.applet.Applet;
  4. import java.awt.Color;
  5. import java.awt.Image;
  6. import java.util.Vector;
  7. import sitemap.SiteMapParserOutput;
  8. import treeview.ImageSet;
  9. import treeview.SiblingChildTree;
  10. import treeview.TreeView;
  11. import treeview.TreeViewNode;
  12.  
  13. public class SiteMapParserToContents implements SiteMapParserOutput {
  14.    protected TreeViewNode root_tree = new TreeViewNode();
  15.    protected int ind = 0;
  16.    protected int real_ind = 0;
  17.    protected Vector parent_list = new Vector();
  18.    protected boolean done_a_node = false;
  19.    protected boolean in_global = true;
  20.    protected Image[] images;
  21.    // $FF: renamed from: a java.applet.Applet
  22.    protected Applet field_0;
  23.    protected TreeView m_tvTheTree = null;
  24.    protected String default_frame_name;
  25.    protected boolean use_folder_images = false;
  26.    protected String name;
  27.    protected String local;
  28.    protected String url;
  29.    protected String frame_name;
  30.    protected boolean new_topic;
  31.    private int m_nItems = 0;
  32.  
  33.    public void end() {
  34.       this.getTree();
  35.       this.m_tvTheTree.setFilled(true);
  36.       this.RemoveEmptyBooks(this.m_tvTheTree.getRoot());
  37.       this.field_0.showStatus("Completing Contents...");
  38.       this.m_tvTheTree.layout();
  39.       this.field_0.showStatus("Done");
  40.       if (this.m_tvTheTree.isVisible()) {
  41.          this.m_tvTheTree.requestFocus();
  42.          this.m_tvTheTree.repaint();
  43.       }
  44.  
  45.       this.m_tvTheTree.setSelectionToTop();
  46.       this.m_tvTheTree.repaint();
  47.    }
  48.  
  49.    public SiteMapParserToContents(Applet var1, Image[] var2) {
  50.       this.field_0 = var1;
  51.       this.images = var2;
  52.       this.parent_list.setSize(1);
  53.       this.parent_list.setElementAt(this.root_tree, 0);
  54.    }
  55.  
  56.    public void object_start() {
  57.       this.in_global = false;
  58.    }
  59.  
  60.    public void indent(int var1) {
  61.       if (var1 == 1) {
  62.          ++this.real_ind;
  63.          if (this.done_a_node) {
  64.             ++this.ind;
  65.          }
  66.       } else if (var1 == -1) {
  67.          this.real_ind += -1;
  68.          this.ind = this.real_ind;
  69.       }
  70.  
  71.       this.done_a_node = false;
  72.    }
  73.  
  74.    public TreeView getTree() {
  75.       if (this.m_tvTheTree == null) {
  76.          this.m_tvTheTree = new TreeView(new ImageSet(this.images), this.root_tree);
  77.       }
  78.  
  79.       this.m_tvTheTree.setApplet(this.field_0);
  80.       this.m_tvTheTree.setBackground(Color.white);
  81.       return this.m_tvTheTree;
  82.    }
  83.  
  84.    public void RemoveEmptyBooks(TreeViewNode var1) {
  85.       if (var1 != null) {
  86.          if (((SiblingChildTree)var1).getChild() != null) {
  87.          }
  88.  
  89.          this.RemoveEmptyBooks((TreeViewNode)((SiblingChildTree)var1).getChild());
  90.          if (((SiblingChildTree)var1).getSibling() != null) {
  91.          }
  92.  
  93.          this.RemoveEmptyBooks((TreeViewNode)((SiblingChildTree)var1).getSibling());
  94.          if (var1 instanceof ContentsTree && ((ContentsTree)var1).local == null && ((SiblingChildTree)var1).getChild() == null) {
  95.             ((SiblingChildTree)var1).pruneThisSubtree();
  96.          }
  97.  
  98.       }
  99.    }
  100.  
  101.    public void start() {
  102.       if (this.m_tvTheTree != null) {
  103.          this.m_tvTheTree.setFilled(false);
  104.          this.m_tvTheTree.requestFocus();
  105.       }
  106.  
  107.       if (this.m_tvTheTree == null) {
  108.          this.m_tvTheTree = new TreeView(new ImageSet(this.images), this.root_tree);
  109.       }
  110.  
  111.    }
  112.  
  113.    public void object_end() {
  114.       if (this.ind < 1 && this.m_tvTheTree.isVisible()) {
  115.          this.m_tvTheTree.repaint();
  116.       }
  117.  
  118.       ContentsTree var1 = new ContentsTree(this.field_0, this.images, this.name, this.local, this.url, this.frame_name == null ? this.default_frame_name : this.frame_name, this.use_folder_images, this.new_topic);
  119.       this.parent_list.setSize(this.ind + 2);
  120.       TreeViewNode var2 = (TreeViewNode)this.parent_list.elementAt(this.ind);
  121.       ((SiblingChildTree)var2).addChild(var1);
  122.       this.parent_list.setElementAt(var1, this.ind + 1);
  123.       this.done_a_node = true;
  124.       if (this.m_nItems % 3 == 0 && this.m_nItems % 4 == 0) {
  125.          this.field_0.showStatus("Loading Table of Contents [" + this.m_nItems + "]...");
  126.       }
  127.  
  128.       ++this.m_nItems;
  129.       this.name = null;
  130.       this.local = null;
  131.       this.frame_name = null;
  132.       this.new_topic = false;
  133.    }
  134.  
  135.    public void param(String var1, String var2) {
  136.       if (this.in_global) {
  137.          if (var1.equalsIgnoreCase("ImageType")) {
  138.             this.use_folder_images = var2.equalsIgnoreCase("Folder");
  139.             return;
  140.          }
  141.  
  142.          if (var1.equalsIgnoreCase("FrameName")) {
  143.             this.default_frame_name = var2;
  144.             return;
  145.          }
  146.       } else {
  147.          switch (Character.toUpperCase(var1.charAt(0))) {
  148.             case 'F':
  149.                if (var1.equalsIgnoreCase("FrameName")) {
  150.                   this.frame_name = var2;
  151.                   return;
  152.                }
  153.                break;
  154.             case 'L':
  155.                if (var1.equalsIgnoreCase("Local")) {
  156.                   this.local = var2;
  157.                   return;
  158.                }
  159.                break;
  160.             case 'N':
  161.                if (var1.equalsIgnoreCase("Name")) {
  162.                   this.name = this.fixSpecialCharacters(var2);
  163.                   return;
  164.                }
  165.  
  166.                if (var1.equalsIgnoreCase("New")) {
  167.                   this.new_topic = var2.equalsIgnoreCase("1");
  168.                   return;
  169.                }
  170.                break;
  171.             case 'U':
  172.                if (var1.equalsIgnoreCase("URL")) {
  173.                   this.url = var2;
  174.                   return;
  175.                }
  176.          }
  177.       }
  178.  
  179.    }
  180.  
  181.    String fixSpecialCharacters(String var1) {
  182.       if (var1 == null) {
  183.          return null;
  184.       } else {
  185.          int var2 = var1.indexOf(38);
  186.          if (var2 < 0) {
  187.             return var1;
  188.          } else {
  189.             String var3 = "";
  190.  
  191.             while(var2 > -1 && var2 < var1.length() - 2) {
  192.                var3 = var3 + var1.substring(0, var2);
  193.                String var4 = var1.substring(var2);
  194.                int var5 = var4.indexOf(59);
  195.                if (var5 < 0) {
  196.                   var3 = var3 + var4;
  197.                   break;
  198.                }
  199.  
  200.                if (var5 < var4.length() - 1) {
  201.                   var1 = var4.substring(var5 + 1);
  202.                } else {
  203.                   var1 = "";
  204.                }
  205.  
  206.                var4 = var4.substring(1, var5);
  207.                switch (Character.toUpperCase(var4.charAt(0))) {
  208.                   case 'A':
  209.                      if (var4.equalsIgnoreCase("amp")) {
  210.                         var4 = "&";
  211.                      }
  212.                      break;
  213.                   case 'C':
  214.                      if (var4.equalsIgnoreCase("copy")) {
  215.                         var4 = "(c)";
  216.                      }
  217.                      break;
  218.                   case 'G':
  219.                      if (var4.equalsIgnoreCase("gt")) {
  220.                         var4 = ">";
  221.                      }
  222.                      break;
  223.                   case 'L':
  224.                      if (var4.equalsIgnoreCase("lt")) {
  225.                         var4 = "<";
  226.                      }
  227.                      break;
  228.                   case 'N':
  229.                      if (var4.equalsIgnoreCase("nbsp")) {
  230.                         var4 = " ";
  231.                      }
  232.                      break;
  233.                   case 'Q':
  234.                      if (var4.equalsIgnoreCase("quot")) {
  235.                         var4 = "\"";
  236.                      }
  237.                      break;
  238.                   case 'R':
  239.                      if (var4.equalsIgnoreCase("reg")) {
  240.                         var4 = "(R)";
  241.                      }
  242.                }
  243.  
  244.                var3 = var3 + var4;
  245.                var2 = var1.indexOf(38);
  246.                if (var2 < 0) {
  247.                   var3 = var3 + var1;
  248.                }
  249.             }
  250.  
  251.             return var3;
  252.          }
  253.       }
  254.    }
  255. }
  256.